package com.base.self.controller;

import com.base.log.LoginAn;
import com.base.result.ResponseResult;
import com.base.self.dto.commodityReferrer.CommodityReferrerDeleteDTO;
import com.base.self.dto.commodityReferrer.CommodityReferrerWebAddDTO;
import com.base.self.dto.commodityReferrer.CommodityReferrerWebListDTO;
import com.base.self.service.ICommodityReferrerService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.validation.Valid;

/**
 * <p>
 * 商品推荐 前端控制器
 * </p>
 *
 * @author XiFYuW
 * @since 2020-11-15
 */
@RestController
@RequestMapping("/admin/commodityReferrer")
public class CommodityReferrerController {

    private final ICommodityReferrerService iCommodityReferrerService;

    public CommodityReferrerController(ICommodityReferrerService iCommodityReferrerService) {
        this.iCommodityReferrerService = iCommodityReferrerService;
    }

    @GetMapping(value = "/commodityReferrerIndex")
    @LoginAn
    public ModelAndView commodityIndex() {
        return new ModelAndView("self/index_commodity_referrer");
    }

    @PostMapping(value = "/commodityReferrerWebList")
    @Validated
    @LoginAn(isRe = true)
    public ResponseResult commodityReferrerWebList(@Valid final CommodityReferrerWebListDTO commodityReferrerWebListDTO) {
        return iCommodityReferrerService.commodityReferrerWebList(commodityReferrerWebListDTO);
    }

    @PostMapping(value = "/commodityReferrerWebAdd")
    @Validated
    @LoginAn(isRe = true)
    public ResponseResult commodityReferrerWebAdd(@Valid final CommodityReferrerWebAddDTO commodityReferrerWebAddDTO) {
        return iCommodityReferrerService.commodityReferrerWebAdd(commodityReferrerWebAddDTO);
    }

    @PostMapping(value = "/commodityReferrerWebDelete")
    @Validated
    @LoginAn(isRe = true)
    public ResponseResult commodityReferrerWebDelete(@Valid final CommodityReferrerDeleteDTO commodityReferrerDeleteDTO) {
        return iCommodityReferrerService.commodityReferrerWebDelete(commodityReferrerDeleteDTO);
    }
}

